package values.quest
{
import com.adobe.serialization.json.JSON;

import core.Configuration;
import core.Language;

/**
 * QuestGoalTemplateValue
 * @author jliang
 * 
 */
public class QuestGoalTemplateValue
{
	[Data(type="field", mapping="@index")]
	public var index:int = 1;
	
	[Data(type="field", mapping="@icon")]
	public var baseIcon:String = "";
	
	public function get icon():String
	{
		return Configuration.assetsPath + baseIcon;
	}
	
	[Data(type="field", mapping="@desc")]
	public var descKey:String = "";
	
	public function get desc():String
	{
		return Language.getText(descKey);
	}
	
	[Data(type="field", mapping="@type")]
	public var type:String = "";
	
	[Data(type="field", mapping="@params")]
	public var params:String = "";
	
	[Data(type="field", mapping="@condition")]
	public var condition:String = "";
	
	public function get conditionObj():Object
	{
		try
		{
			return JSON.decode(condition);
		}
		catch (error:Error)
		{
			
		}
		return condition;
	}
	
	[Data(type="field", mapping="@skip_cost")]
	public var skipCost:Number = 0;
	
	private var _owner:QuestTemplateValue;
	
	public function get owner():QuestTemplateValue
	{
		return _owner;
	}
	
	[Data(type="mapping", 
		  	way="belong")]
	public function set owner(value:QuestTemplateValue):void
	{
		_owner = value;
	}
}
}